<template>
	<view class="fenleiBoxCCrr">
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<view>
			<vtop-tabs lineHeight="6rpx" :lineScale="0.4" paddingItem="0 24rpx" :bold="true"
				v-model="selectTabCurrentChaoren" field="text" :tabs="scrollTopDataChaoren"
				@change="changeCurrentTabChaoren"></vtop-tabs>
		</view>
		<view class="fenlei_bot_box_ccrr">
			<view class="fenlei_bot_item_ccrr" v-for="(j, index) in leftProductListChaoren" :key="index"
				:style="{'margin-right':index % 2 === 1?'':'4%'}"
				@click="$onTo(j.price == undefined ? `/pagesClass-rich/classified1-rich/classified1-rich?id=${j.id}` : `/pagesClass-rich/product/product?productId=${j.itemId}`)">
				<!-- <view> -->
				<image :src="j.image || j.src" class="fenlei_img_ccrr" mode="aspectFit"></image>
				<!-- </view> -->
				<view class="fenlei_title_ccrr">
					<text class="fenlei_title1_ccrr">{{ j.name }}</text>
					<!-- <text class="pinyin_ccrr">{{exchangePinyin(j.name)}}</text> -->
				</view>
			</view>
		</view>
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
		<!-- 潮人奢购-->
	</view>
</template>

<script>
	import fenleiService from './services';
	import VtopTabs from '../../components/class-vtabs/class-vtabs.vue';
	let pinyin = require('js-pinyin');
	pinyin.setOptions({
		checkPolyphone: false,
		charCase: 2
	});
	export default {
		data() {
			return {
				scrollTopDataChaoren: [],
				leftProductListChaoren: [], //分类二级标签列表
				selectTabCurrentChaoren: 0,
				tabGoodsDataChaoren: [], //分类列表
				rezhuLIstCCrr: [], //和首页热阻组件同步的热租榜的数据
				rezhuStaCCrr: false, //从本地存储里面里判断热租组件是否存在






				//下面是没用的垃圾混淆代码
				renzhengTimeSta1111111: true, //初次请求认证时间默认是带有的，
				zhuceTimeSta11111: false, //初次请求注册时间默认是没有的
				renzhengTimeList11111: [],
				zhuceTimeStaList1111: null,
				detailOrderIdStr11111: '',
				threeTabCurrent1111: 0,
				applyGOodsList11111: [], //供货商列表
				allCardEnterSta1111: false, //默认是false，点击批量卡券入库的时候变为true
				codeAddNumsList11111: [],
				numsList11111: [],
				dataSourceBqcp1111: [],
				selectedRowKeys1111: [],
				selectedRowKeysB11111: [],
				rkVisible11111: false,
				rkjlVisible1111: false,
				lhjlVisible1111: false,
				currentStyleData22222: {},
				dataSourceStyle2222: [],
				showStyleData2222: false,
				indexTemplate2222: [],
				SVGCircleElement3ee: '',
				vshoweqwsc1111: false,
				showStyleDataInfo2222: false,
				opeCategoryList2222: [],
				leimuVisible2222: false,
				selectedRowKeys02222: [],
				selectionRows02222: [],
				selectedRowKeys133333: [],
				selectionRows13333: [],
				selectedRowKeys2333: [],
				selectionRows23333: [],
				selectedRowKeys33333: [],
				selectionRows33333: [],
				selectedRowKeys4333: [],
				selectionRows43333: [],
				curwfqwrentStyleDaterwaInfo444: {},
				currwerentStywerleDatweraInfo1444: {},
				currewerntStyleDataInfo24444: {},
				currentweStyleDytuataIwenfo34444: {},
				currenwetStdfgyleDataInfo44444: {},
				checkZfbPhone_h5444: '',
				plNafgdvfdtjyme4444: '', //四大品类的名字
				uniPdfgrtylatform444: '', //运行环境mp-alipay mp-weixin
				refgjtytrsemark555: '', //备注
				timefgjSelStr5555: '', //选择的上门时间（2023-08-31 00:00:00）
				amOdcuiofasrpm5555: '', //选择的上门时间是上午还是下午
				pageShnjlkgohowTime5555: '', //页面上用户看到的显示的时间
				paraghsdfmsw454: {},
				valhgujtueNum56756: 0,
				addrdraess56756: {}, //上门收货地址
				adawerterydressId575: 0,
				sceoyuitne57567: '',
				tntuiopId56757: '',
				weictyuratCustomer5756: '',
				yuidurtyuoy567567: false,
			};
		},

		components: {
			VtopTabs
		},
		watch: {},

		onLoad() {
			let value11 = uni.getStorageSync('rezuListState');
			if (value11) {
				this.rezhuStaCCrr = true;
				this.rezhuLIstCCrr = JSON.parse(value11);
				this.leftProductListChaoren = this.rezhuLIstCCrr;
			}
			this.getMainDataCCrr(0);
		},

		methods: {
			//把中午转成拼音
			exchangePinyin(text) {
				return pinyin.getCamelChars(text)
			},

			//获取首页热租产品
			getRezuGoodListCCrr() {
				if (this.rezhuStaCCrr) {
					this.leftProductListChaoren = this.rezhuLIstCCrr;
				}
			},
			getMainDataCCrr(parentId) {
				fenleiService
					.fenleiListLite({
						parentId
					})
					.then((res) => {
						if (parentId === 0) {
							console.log('走的上面的');
							this.getMainDataCCrr(res.data[0].id);
							this.tabGoodsDataChaoren = res.data;
							this.scrollTopDataChaoren = []
							res.data.forEach(item => {
								this.scrollTopDataChaoren.push({
									text: item.name,
									id: item.id
								})
							})
						} else {
							//获取二级分类列表
							console.log('走的下面的');
							this.leftProductListChaoren = res.data;
							if (this.selectTabCurrentChaoren != -1) {} else {
								this.getRezuGoodListCCrr();
							}
						}
					});
			},
			//切换分类标签下标
			changeCurrentTabChaoren(index) {
				console.log('--当前下标--', index);
				//保存当前下标
				this.selectTabCurrentChaoren = index;
				//重置二级分类标签下标
				if (index != -1) {
					this.getMainDataCCrr(this.tabGoodsDataChaoren[index].id);
				} else {
					this.getRezuGoodListCCrr();
				}
			},
		}
	};
</script>

<style lang="scss" scoped>
	.fenleiBoxCCrr {
		position: relative;

		.fenlei_bot_box_ccrr {
			margin: 30rpx auto 0 auto;
			width: 95%;
			box-sizing: border-box;
			flex-wrap: wrap;
			display: flex;

			.fenlei_bot_item_ccrr {
				border: 2rpx solid #f35111;
				display: flex;
				justify-content: center;
				align-items: center;
				// justify-content: space-evenly;
				border-radius: 20rpx;
				width: 48%;
				margin-bottom: 10px;
				height: 120rpx;

				.fenlei_img_ccrr {
					height: 70rpx;
					width: 70rpx;
					// margin-left: 20rpx;
					margin-right: 30rpx;
				}


				.fenlei_title_ccrr {
					padding-right: 5rpx;
					overflow: hidden;
					box-sizing: border-box;
					margin-bottom: 10rpx;
					justify-content: space-evenly;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					display: flex;
					align-items: flex-start;
					flex-direction: column;


					.fenlei_title1_ccrr {
						word-break: break-all;
						letter-spacing: 0.1em;
						font-family: Arial;
						color: #333333;
						font-size: 24rpx;
						font-weight: 400;
					}

					.pinyin_ccrr {
						text-overflow: ellipsis;
						letter-spacing: 0.1em;
						overflow: hidden;
						white-space: nowrap;
					}
				}
			}
		}
	}
</style>